<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 代理+反射
        let formData = {
            account: "admin",
            password: '123456'
        };
        // 账号：6~20
        // 密码：6~20
        let handel = {
            set: function(target, key, value) {
                if (value.length < 6 || value.length > 20) {
                    return;
                }
                target[key] = value;
            },
            get: function(target, key) {
                console.log("get函数被调用:", target, key);
                return target[key];
            }
        }
        formData = new Proxy(formData, handel);
        Reflect.set(formData, 'account', 'admin123');
        Reflect.set(formData, 'accoumt', '123');
        let accoumt = Reflect.get(formData, 'account');
        let password = Reflect.get(formData, 'password');
        console.log(accoumt, password);
    </script>
</body>

</html>